import service from "../api/config";

// 获取&刷新验证码请求
export const captcha = () => {
  return service.get("/api/users/getCaptcha");
};

// 校验验证码
export const verifiCation = (catcha) => {
  return service.get(`/api/users/verifyCaptcha?captcha=${catcha}`);
};

// 账号密码验证
export const login = (username, password) => {
  return service.post("/api/users/login", {
    username,
    password,
  });
};

// 获取日志
export const getLogs = (page, count) => {
  return service.get(`/api/getloginlog?page=${page}&count=${count}`);
};

// 获取权限
export const getMenuList = () => {
  return service.get("/api/permission/getMenuList");
};

// 获取信息接口
export const getUserInfo = (config) => {
  return service.get("/api/students/getstulist", {
    params: {
      page: config.page,
      count: config.count,
      class: config.classes,
    },
  });
};

// 搜索接口
export const searchStu = (page = 1, count = "5", key = "") => {
  return service.get("/api/students/searchstu", {
    params: {
      key,
      count,
      page,
    },
  });
};

//获取任务数据
export const getTarskData = () => service.get("/data/tarsk.json");

//获取rate数据
export const getRateData = () => service.get("/data/rate.json");

//获取expect数据
export const getExpectData = () => service.get("/data/expect.json");

// 天气接口
export const weather = () => service.get("/api/weather/getWeather");

// 增加学员信息
export const addUser = ({
  name,
  age,
  city,
  degree,
  productUrl,
  description,
  headimgurl,
  classess,
}) =>
  service.post("/api/students/addstu", {
    name,
    age,
    city,
    degree,
    productUrl,
    description,
    headimgurl,
    class: classess,
  });

// 删除学员信息
export const delUser = (sId) =>
  service.get("/api//students/delstu", {
    params: {
      sId,
    },
  });

// 修改学员信息
export const editUser = ({
  sId,
  token,
  name,
  age,
  city,
  degree,
  productUrl,
  description,
  headimgurl,
  classess,
}) =>
  service.post("/api/students/updatestu", {
    sId,
    token,
    name,
    age,
    city,
    degree,
    productUrl,
    description,
    headimgurl,
    class: classess,
  });
